package cn.tedu.store.service;

import java.util.List;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import cn.tedu.store.vo.CartVO;

@RunWith(SpringRunner.class)
@SpringBootTest
public class CartServiceTestCase {
	@Autowired
	private ICartService service;
	
	@Test
	public void getByCids() {
		Integer[] cids= {10,11,12,13,14,15,16};
		Integer uid=28;
		List<CartVO> list = service.getByCids(cids, uid);
		for (CartVO cartVO : list) {
			System.err.println(cartVO);
		}
	}
	
	
	@Test
	public void add() {
		Integer cid=11;
		Integer uid=28;
		String username="朱上林";
		try {
			Integer num = service.addNum(cid, uid, username);
			System.err.println("现在的数量是："+num);
		} catch (Exception e) {
			System.err.println(e.getClass().getName());
			System.err.println(e.getMessage());
		}
	
	}
	
	@Test
	public void addToCart() {
		try {
			service.addToCart(5, 3L, 2, "ROOT");
			System.err.println("添加到购物车成功");
		} catch (Exception e) {
			System.err.println(e.getClass().getName());
			System.err.println(e.getMessage());
		}
		
	}
	
	@Test
	public void getByUid() {
		try {
			Integer uid=28;
			List<CartVO> carts = service.getByUid(uid);
			System.err.println("BEGIN");
			for (CartVO cartVO : carts) {
				System.err.println(cartVO);
			}
			System.err.println("END");
		} catch (Exception e) {
			// TODO: handle exception
		}
	}
	
	
}
